<?php
/**
 * 描述：杂志期刊-主页。
 * @final
 */
final class Exec_Magazine_Index extends Exec
{
    public function Get()
    {
        #获取数据-特别推荐
        $data=DB::GetRowByID('dm_other','ID:1');
        if($data){
            $data['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$data['ThumbnailPath'];
        }
        View::Assign('Ejournal_Index_Recommend',$data);

        #获取数据-每期头条
        $data=DB::GetRowByID('dm_other','ID:2');
        $data['ThumbnailPath']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$data['ThumbnailPath'];
        View::Assign('Ejournal_Index_Headline',$data);

        #获取数据-最新杂志
        $data=DB::GetRows('select * from dm order by ID desc limit 0,1');
        if($data){
            $data=$data[0];
            $data['CoverLocation']=Config::PATH_RELATIVE_ATTACHMENT_TEMP.'/'.$data['CoverLocation'];
        }
        View::Assign('Ejournal_Index_LatestDM',$data);
        
        #获取数据-合作展会
        $data=DB::GetRows('select * from exhibition_infos where M_IsCooperation=TRUE order by ID desc limit 0,8');
        View::Assign('Ejournal_Index_CooperationExhibition',$data);

        #获取数据-最新期刊
        $data=DB::GetRows('select * from ejournal order by ID desc limit 0,1');
        if($data){
            $data=$data[0];
        }
        View::Assign('Ejournal_Index_LatestEjournal',$data);

        #渲染输出
        View::Display('magazine/index.tpl');
    }

    /**
     * 描述：杂志订阅。
     * @access public
     */
    public function Post()
    {
        #获取数据
        $data=array
        (
            'CompanyName'=>Functions::FormArgs('CompanyName',200,TRUE),
            'Linkman'=>Functions::FormArgs('Linkman',200,TRUE),
            'PhoneNumber'=>Functions::FormArgs('PhoneNumber',200,TRUE),
            'Email'=>Functions::FormArgs('Email',200,TRUE),
            'Postcode'=>Functions::FormArgs('Postcode',200,TRUE),
            'Address'=>Functions::FormArgs('Address',200,TRUE),
        );
        
        #插入数据
        DB::Insert('dm_subscription',$data);
        echo 'Success';
    }
}
?>